package afcp.alumni.model.db;

import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import afcp.alumni.dao.RoleDao;
import afcp.alumni.model.base.DatastoreEntity;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

//@Entity
@PersistenceCapable
public class RolesAncestor implements DatastoreEntity {

	public RolesAncestor() {
		this.id = RoleDao.ANCESTOR_ID;
//		this.setKey(KeyFactory.createKey(this.getClass().getSimpleName(), RoleDao.ANCESTOR_ID));
	}
	
//	@Id
	@PrimaryKey
	@Persistent
	private Key key;
	@Persistent
	private String id;

	public String getId() {
		return id;
	}

	@Override
	public Key getKey() {
		return key;
	}

	@Override
	public void setKeyWithAncestor(Key ancestorKey) {
		this.key = KeyFactory.createKey(ancestorKey, this.getClass().getSimpleName(), RoleDao.ANCESTOR_ID);
	}

	public void setId(String id) {
		this.id = id;
	}
	
	@Override
	public String toString() {
		return id;
	}
}
